
<script setup>
import { ref } from 'vue';
import axios from 'axios'
import { ElMessage } from 'element-plus'

const name = ref('')
const password = ref('')
const sSubmit = ()=>{
    console.log();
axios.post('http://localhost:3000/api/v1/auth/admin_login',
  {
    userName:name.value,
  pwd:password.value
  }
).then(req=>{
    console.log(req);
    console.log(req.data.data);
    let token = req.data.data;
    console.log(token);
    if(token == ''){
        ElMessage({
    message: req.data.errorMessage,
    type: 'error',
  })}else{
// 存本地令牌
localStorage.setItem('token',token)
ElMessage({
    message: req.data.errorMessage,
    type: 'success',
  })
    // location 这得用路由了 hash路由得加#

    setTimeout(() => {
    location.href = '/#/content' ;
    }, 800);
  }


})
}

        
</script>

<template >
      <div class="img">
        <div class="login">
            <h2>LOGIN</h2>
        <el-input v-model="name" placeholder="请输入账号" clearable />
        <el-input v-model="password"  type="password"  placeholder="请输入密码"   show-password/>
        <el-button @click="sSubmit" type="primary" style="width: 90%;">按钮</el-button>
        <el-button style="display: none;" :plain="true" @click="open4"></el-button >
        </div>

      </div>
</template>
<style scoped lang="scss">

    
    .img{
      display:flex;
      background: url(./bgk.jpg) ;
      // background-size:cover;
      height:100vh;
      .login{
        background:rgba(255,255,255,.5);
        width: 600px;
        height: 500px;
        box-shadow:  0 0 5px gray;
        margin: auto;
        display: flex;
        justify-content: center;
        flex-direction: column;
        align-items: center;
        border-radius: 10px;
        
        .el-input{width: 90%;margin-bottom: 20px;} 
    }
    }
</style>